/*
 * DatabaseTools.java
 *
 * Copyright(c) 2010
 * Michael Kroez
 * kroez@studiorutton.de
 *
 * All rights reserved.
 *
 * $Id$
 * 
 */

package de.studiorutton.gerengdic.databaseaccess;

import java.nio.charset.Charset;

public class DatabaseTools {

	public static final Charset CHARSET_DEFAULT = Charset.forName( "UTF-8" );
	public static final int INT_SIZE = 4;
	public static final int HEADER_SIZE = 1;
	public static final int BYTE_SIZE = 1;
	// public static final byte NULL_BYTE = 0x00;
	
	public static final int byteArrayToInt(byte[] b) {
		return (b[0] << 24) + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF) << 8)
				+ (b[3] & 0xFF);
	}

	public static final byte[] intToByteArray(int value) {
		return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16),
				(byte) (value >>> 8), (byte) value };
	}
}
